/// gaoruisahn
/// 腕带绑定登记号
Class CF.NUR.MNISV3.RfidBindRegNo Extends %Persistent [ ClassType = persistent, ProcedureBlock ]
{

/// 唯一码
Property RfidId As %String(TRUNCATE = 1);

/// 登记号
Property RegNo As %String(TRUNCATE = 1);

/// 类型: RFID 和 INF
Property Type As %String(TRUNCATE = 1);

Property BindDate As %Date [ InitialExpression = {$p($h,",",1)} ];

Property BindTime As %Time [ InitialExpression = {$p($h,",",2)} ];

Property BindUser As %String;

Property UnbindDate As %Date;

Property UnbindTime As %Time;

Property UnbindUser As %String;

Index BindId On (RegNo, RfidId);

Index RfidId On (RfidId, RegNo);

/// Description:    绑定  
/// Input           唯一码 登记号
/// Return：     ""
/// Method          w ##class(CF.NUR.MNIS.RfidBindRegNo).Save()
ClassMethod Save(rfidId As %String, regNo As %String, userId = "", type = "RFID") As %String
{
    s obj=##class(CF.NUR.MNISV3.RfidBindRegNo).%New()
    s obj.RfidId=rfidId
    s obj.RegNo=regNo
    i $g(userId)'=""  s obj.BindUser=userId
    i $g(type)'=""  s obj.Type=type
    d obj.%Save()
    d obj.%Close()
    q 0
}

/// Description:    解绑  
/// Input           唯一码
/// Return：     ""
/// Method          w ##class(CF.NUR.MNIS.RfidBindRegNo).Delete("1")
ClassMethod Delete(bindId) As %String
{
    s obj=##class(CF.NUR.MNISV3.RfidBindRegNo).%OpenId(bindId)
    d obj.%DeleteId(bindId)
    q 0
}

Storage Default
{
<Data name="RfidBindRegNoDefaultData">
<Value name="1">
<Value>%%CLASSNAME</Value>
</Value>
<Value name="2">
<Value>RfidId</Value>
</Value>
<Value name="3">
<Value>RegNo</Value>
</Value>
<Value name="4">
<Value>Type</Value>
</Value>
<Value name="5">
<Value>BindDate</Value>
</Value>
<Value name="6">
<Value>BindTime</Value>
</Value>
<Value name="7">
<Value>BindUser</Value>
</Value>
<Value name="8">
<Value>UnbindDate</Value>
</Value>
<Value name="9">
<Value>UnbindTime</Value>
</Value>
<Value name="10">
<Value>UnbindUser</Value>
</Value>
</Data>
<DataLocation>^CF.NUR.MNISV3.RfidBindRegNoD</DataLocation>
<DefaultData>RfidBindRegNoDefaultData</DefaultData>
<IdLocation>^CF.NUR.MNISV3.RfidBindRegNoD</IdLocation>
<IndexLocation>^CF.NUR.MNISV3.RfidBindRegNoI</IndexLocation>
<StreamLocation>^CF.NUR.MNISV3.RfidBindRegNoS</StreamLocation>
<Type>%Storage.Persistent</Type>
}

}
